package com.cloud.code.牛客网;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test34 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String config = scanner.nextLine();
            String nums = scanner.nextLine();
            String[] nums2 = nums.split(",");
            String[] split = config.split(",");
            List<Integer> list = new ArrayList<>();
            for (int i = 0; i < split.length; i++) {

                String[] split1 = split[i].split(":");
                for (int s = 0; s < Integer.parseInt(split1[1]); s++) {
                    list.add(Integer.valueOf(split1[0]));
                }

            }

            List<Integer> list1 = new ArrayList<>();
            for (int i = 0; i < nums2.length; i++) {

                for (int j = 0; j < list.size(); j++) {
                    if (list1.contains(j)) {
                        continue;
                    }
                    if (list.get(j) >= Integer.parseInt(nums2[i])) {
                        list1.add(j);
                        System.out.println("true");
                        break;
                    }

                    if (j == list.size() - 1 && list.get(j) < Integer.parseInt(nums2[i])) {
                        System.out.println("false");
                    }

                }

            }


        }
    }
}
